// JavaScript Document

function addRolesRow(tableID)
{
	counter = document.getElementById("criteria_counter").value;
	var i = counter-1;

	if(document.getElementById("text_user_name") != null)
	{
	
		if(document.getElementById("text_user_name").value=="")
		{
			message = "Please Enter UserName Before Adding the Roles";
			alert(message);
			document.getElementById("text_user_name").focus();
			return false;
		}
		
		var table  =  document.all ? document.all[tableID] : document.getElementById(tableID);
		if (document.all || document.getElementById)
		{
			var row  = table.insertRow(table.rows.length-2);
			var cell1 = row.insertCell(0);
			var cell2 = row.insertCell(1);
			var cell3 = row.insertCell(2);
			var cell4 = row.insertCell(3);
		
					
			row.setAttribute( 'id' , 'role'+counter);
			cell1.innerHTML = '<td class="Labels">Page Access</td>';
			
			var str = '<select name="combo_page[]" id="combo_page'+counter+'" class="InputComboList">';
			
			for(i=0; i<document.getElementById("combo_page0").options.length; i++) {
				
				str += "<option value=\"" + document.getElementById("combo_page0").options[i].value +"\">" +
				        document.getElementById("combo_page0").options[i].text+"</option>";
			   
			}
			str += "</select>";
			cell2.innerHTML  = str;		
			
			cell3.innerHTML  = '<input type="button" name="btn_addRolesRow" id="'+'btn_addRolesRow'+counter+'" class="InputButton" value="Add" onClick="addRolesRow(\'table1\');" ></td>';
			cell4.innerHTML  = '<input type="button" name="'+'role'+counter+'_btn" id="'+'role'+counter+'_btn" class="InputButton" value="Remove" onClick="removeCriteriaRow(\'table1\',this);" ></td>';

	counter++;
	document.getElementById("criteria_counter").value= counter;	
		}
	}
	
}

	
